Skip to main content

HttpFunctionAdapter

@h4ad/serverless-adapter > HttpFunctionAdapter

(class) HttpFunctionAdapter

The adapter to handle requests from Digital Ocean Functions when called from HTTP Endpoint.

Signature:

export declare class HttpFunctionAdapter implements AdapterContract<DigitalOceanHttpEvent, void, DigitalOceanHttpResponse> 

Implements: AdapterContract <DigitalOceanHttpEvent, void, DigitalOceanHttpResponse>

Example

const stripBasePath = '/any/custom/base/path'; // default ''
const adapter = new HttpFunctionAdapter(\{ stripBasePath });

(constructor)

Default constructor

Signature:

constructor(options?: HttpFunctionAdapterOptions | undefined);

Parameters

ParameterTypeDescription
optionsHttpFunctionAdapterOptions | undefined(Optional) The options to customize the HttpFunctionAdapter

(method) canHandle

Signature:

canHandle(event: unknown): event is DigitalOceanHttpEvent;

Parameters

ParameterTypeDescription
eventunknown

Returns:

event is DigitalOceanHttpEvent

(method) getAdapterName

Signature:

getAdapterName(): string;

Returns:

string

(method) getPathFromEvent

Get path from event with query strings

Signature:

protected getPathFromEvent(event: DigitalOceanHttpEvent): string;

Parameters

ParameterTypeDescription
eventDigitalOceanHttpEventThe event sent by digital ocean

Returns:

string

(method) getRequest

Signature:

getRequest(event: DigitalOceanHttpEvent): AdapterRequest;

Parameters

ParameterTypeDescription
eventDigitalOceanHttpEvent

Returns:

AdapterRequest

(method) getResponse

Signature:

getResponse(\{ headers: responseHeaders, body, statusCode, }: GetResponseAdapterProps<DigitalOceanHttpEvent>): DigitalOceanHttpResponse;

Parameters

ParameterTypeDescription
{ headers: responseHeaders, body, statusCode, }GetResponseAdapterProps <DigitalOceanHttpEvent>

Returns:

DigitalOceanHttpResponse

(method) onErrorWhileForwarding

Signature:

onErrorWhileForwarding(\{ error, delegatedResolver, respondWithErrors, event, log, }: OnErrorProps<DigitalOceanHttpEvent, DigitalOceanHttpResponse>): void;

Parameters

ParameterTypeDescription
{ error, delegatedResolver, respondWithErrors, event, log, }OnErrorProps <DigitalOceanHttpEvent, DigitalOceanHttpResponse>

Returns:

void

(property) options

Signature:

protected readonly options?: HttpFunctionAdapterOptions | undefined;